import request from "./Request.js";

/**
 * 获取嘿文
 */
export function getHeis(schoolName = "") {
	return request({
		url: "/heis",
		data: {
			schoolName: schoolName
		},
		method: "GET"
	});
}

/**
 * 根据嘿文 ID 获取嘿文
 */
export function getHeiById(id) {
	return request({
		url: "/hei",
		data: {
			id: id
		},
		method: "GET"
	});
}

/**
 * 添加喜欢的嘿文
 */
export function addHeiLike(heiId) {
	return request({
		url: "/hei/like",
		data: {
			id: heiId
		},
		method: "POST"
	});
}

/**
 * 获取用户喜欢和收藏的嘿文
 */
export function getLikeAndCollect() {
	return request({
		url: "/hei/likeAndCollect",
		method: "GET"
	});
}

/**
 * 删除喜欢的嘿文
 */
export function deleteHeiLike(heiId) {
	return request({
		url: "/hei/like",
		data: {
			id: heiId
		},
		method: "DELETE"
	});
}

/**
 * 添加收藏的嘿文
 */
export function addHeiCollect(heiId) {
	return request({
		url: "/hei/collect",
		data: {
			id: heiId
		},
		method: "POST"
	});
}

/**
 * 删除收藏的嘿文
 */
export function deleteHeiCollect(heiId) {
	return request({
		url: "/hei/collect",
		data: {
			id: heiId
		},
		method: "DELETE"
	});
}

/**
 * 获取用户喜欢的嘿文
 */
export function getLikeHei() {
	return request({
		url: "/hei/likeHei",
		method: "GET"
	});
}

/**
 * 获取用户收藏的嘿文
 */
export function getCollectHei() {
	return request({
		url: "/hei/collectHei",
		method: "GET"
	});
}

/**
 * 根据邮箱获取嘿文
 */
export function getHeiByEmail(email) {
	return request({
		url: "/hei/getByEmail",
		data: {
			byEmail: email
		},
		method: "GET"
	});
}

/**
 * 根据邮箱获取嘿文数量
 */
export function getHeiCount() {
	return request({
		url: "/hei/myCount",
		method: "GET"
	});
}

/**
 * 根据嘿文 ID 删除嘿文
 */
export function deleteHei(heiId) {
	return request({
		url: "/hei",
		data: {
			heiId: heiId
		},
		method: "DELETE"
	});
}

/**
 * 根据嘿文图片 ID 删除图片
 */
export function deleteHeiImage(heiImageId) {
	return request({
		url: "/heiImage",
		data: {
			heiImageId: heiImageId
		},
		method: "DELETE"
	});
}

/**
 * 修改嘿文（此接口仅用于没有新图片上传，即只修改嘿文标题和内容情况下使用）
 */
export function updateHei(title, content, heiId) {
	return request({
		url: "/hei/updateNoImg",
		data: {
			title: title,
			content: content,
			heiId: heiId,
		},
		method: "POST"
	});
}